/**
 *  快递单记录页面js
 * 版权所有：上海戈品投资管理有限公司
 *   author king
     功能说明：快递单记录查询
     创建日期：2015-10-12
     修改记录：
     备注说明：
 */


$(document).ready(function() {
	receiveOrderList();
});

/**
 * 接单管理查询
 * @returns
 */
var receiveOrderList = function(){

	var userId=$("#userId").val();
	
	 var datas =  {"p":"expressOrder","m":"queryEpSearchRecord","userID":userId};
	 var columnDefine = {"id":"编号","userID":"快递员ID","expressCode":"快递单号","epCodeStatus":"快递状态","companyName":"快递公司","searchTime":"查询快递单时间","userType":"用户类型"};
	 var formatters={
	            "searchTime": function (column, rowData)
	            {
	            	return timeFormatTrans(rowData.searchTime*1000);
	            },
	            "epCodeStatus": function (column, rowData)
	            {
	            	var status;
	            	switch(rowData.epCodeStatus){
	            	case -1:
	            		status = '待查询';
	            		break;
	            	case 0:
	            		status = '查询异常';
	            		break;
	            	case 1:
	            		status = '暂无记录';
	            		break;
	            	case 2:
	            		status = '在途中';
	            		break;
	            	case 3:
	            		status = '派送中';
	            		break;
	            	case 4:
	            		status = '已签收'; 
	            		break;
	            	case 5:
	            		status = '用户拒签';
	            		break;
	            	case 6:
	            		status = '疑难件';
	            		break;
	            	case 7:
	            		status = '无效单';
	            		break;
	            	case 8:
	            		status = '超时单';
	            		break;
	            	case 9:
	            		status = '签收失败';
	            		break;
	            	case 10:
	            		status = '退回';
	            		break;
	            	}
	            	return status;
	            }
	 };
	 var buttons =''; //操作按钮
		buttons+='<p>';
		buttons+='</p>';
	hui.pager('service',datas ,"dataList", columnDefine , formatters , buttons ); //分页查询
	 
};

var getTheSureTime=function(emp){
	return emp>9?emp:"0"+emp;
}
//时间格式转换
var timeFormatTrans=function(time){
	var newTime= new Date(time);
	var rowText=newTime.getFullYear()+'-'+getTheSureTime((newTime.getMonth()+1))+'-'
	+getTheSureTime(newTime.getDate())+' '+getTheSureTime(newTime.getHours())+':'
	+getTheSureTime(newTime.getMinutes())+':'+getTheSureTime(newTime.getSeconds());
	return rowText;
};

